package org.springblade.modules.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springblade.core.tool.api.R;
import org.springblade.modules.admin.entity.ElevatorDetail;
import org.springblade.modules.admin.service.IElevatorDetailService;
import org.springblade.modules.admin.service.IElevatorNumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 电梯唯一、快速识别码
 * @author: Sharry
 * @createTime: 2023/4/19 13:52
 * @version: Version-1.0
 */
@Api(tags = "获取电梯唯一快速识别码", value = "/elevator/num")
@RestController
@RequestMapping("/elevator/num")
public class ElevatorNumController {

	@Autowired
	private IElevatorNumService elevatorNumService;

	@Autowired
	private IElevatorDetailService eds;

	@GetMapping("/void")
	public void generate(){
		elevatorNumService.generateElevatorNumBatch();
	}

	@GetMapping("/getNum")
	@ApiOperation("获取电梯唯一快速识别码")
	@ApiOperationSupport(order = 10)
	@ApiImplicitParam(name = "elevatorId", value = "当前电梯id", example = "1382934961591468033")
	public R<String> getEleNum (Long elevatorId){
		return R.data(elevatorNumService.getEleNumById(elevatorId));
	}

	@GetMapping("/getList")
	@ApiOperation("搜索框获取电梯快速识别码列表")
	@ApiOperationSupport(order = 11)
	public R<List<String>> getNumList(){
		List<ElevatorDetail> list = eds.list();
		List<String> enList = new ArrayList<>();
		list.forEach(l -> enList.add(l.getElevatorNum()));
		return R.data(enList);
	}

}
